package top.zuli.package02.homework15;

public class Demo {
    public String ar(String str, int startIndex, int endIndex) {
        if (str != null) {
            char[] arr = str.toCharArray();
            for (int x = startIndex, y = endIndex; x < y; x++, y--) {
                char temp = arr[x];
                arr[x] = arr[y];
                arr[y] = temp;
            }
            return new String(arr);
        }
        return null;
    }

}
class test{
    public static void main(String[] args) {
        Demo demo = new Demo();
        String result = demo.ar("abcdefg", 1, 5);
        System.out.println(result);
    }
}
